home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / onefos08.zip / ONEREF.TXT < prev    next >
Text File  |  1996-01-11  |  51KB  |  1,158 lines

  1.              Functions Reference Manual for the ONEFOSsil Developer
  2.            (c) Copyright 1995-96 by Carl Morris and Morris Softronics
  3.       ONEFOSsil, A low level serial communications driver for MS-DOS based
  4.                         FOSSIL 5 compliant applications.
  5.  
  6.     Introduction
  7.  
  8.     This document is for developers wanting to use ONEFOSsil specific
  9.     features and for developers just learning about the FOSSIL
  10.     specification.  ONEFOSsil supports most FOSSIL 5 and X00 extended
  11.     functions, and this document will help describe any differences.
  12.     Portions of this document are copyright by VEP Software, Rick Moore, and
  13.     Raymond Gwinn.  The rest of this document is copyright by Morris
  14.     Softronics and Carl Morris.
  15.  
  16.     This documentation is distributed as is and is provided with no
  17.     guarantees.  You use the information contained within at your own risk.
  18.  
  19.     What is ONEFOSsil and a FOSSIL driver?
  20.  
  21.     ONEFOSsil is a simplified serial communications driver for 8250 series
  22.     UART's and MS-DOS based machines running applications requiring a simple
  23.     FOSSIL 5 communications driver.  ONEFOSsil only provides FOSSIL based
  24.     services.
  25.  
  26.     FOSSIL is an acronym derived from Fido Opus Seadog Standard Interface
  27.     Layer.  The FOSSIL specification was intended to permit machine
  28.     independent software (Fido, Opus, and Seadog at the time) to be created
  29.     and ran on any MS-DOS based 8086 based computer that had a FOSSIL
  30.     compatible driver.  Those days are much over, and FOSSIL compatible
  31.     drivers are only used as a low level communications interface for
  32.     application software.  A better specification is needed to keep up with
  33.     today's quickly changing world, though.
  34.  
  35.     ONEFOSsil does not maintain total compatibility with the FOSSIL 5
  36.     specification.  These differences will be noted in this document, but
  37.     will seldom cause problems with most modern software.
  38.  
  39.     Interface
  40.  
  41.     ONEFOSsil's Application Program Interface is partly based on the PC BIOS
  42.     communications interface.  As such, the driver will be entered with an
  43.     8086 instruction INT 14h.  A function number is passed in 8086 register
  44.     AH and other registers are used as needed.  Return codes from functions
  45.     will very from function to function, and is one of the most confusing
  46.     aspect of FOSSIL programming; they're not logical!
  47.  
  48.     Registers are not modified by ONEFOSsil unless otherwise specified.
  49.     Note that this is not true about all FOSSIL drivers.  While this
  50.     document covers basic FOSSIL functions, some differences will be
  51.     encountered from FOSSIL to FOSSIL.
  52.  
  53.     In most cases, functions will require a port number to operate.  In all
  54.     cases, port numbers are passed in register DX.  Most FOSSIL's only
  55.     support ports 0 - 7.  FOSSIL to DigiBoard converters usually only
  56.     support 0 - 15.  ONEFOSsil supports ports 0 - 63.  Notice that in most
  57.     cases, the port number is one less than the COM port number; but, in
  58.     most FOSSIL's, the port can be specified on any address/irq combination,
  59.     or may not even map to a COM port at all.
  60.  
  61.     As a note to developers, FOSSIL functions should not be called in a way
  62.     that could cause active code to be reentered.  ONEFOSsil and many other
  63.     FOSSIL's are re-entrant, but not to that great of a degree.
  64.  
  65.     Detection
  66.  
  67.     Detecting FOSSIL drivers vary.  The FOSSIL specification states that to
  68.     detect a FOSSIL, one should look at the 6th byte (3rd word) after the
  69.     start of the INT 14h service routine for the word 1954h, followed by a
  70.     byte, the maximum function supported by the FOSSIL driver.  However,
  71.     this is unreliable if other utilities and/or drivers have hooked the INT
  72.     14h interrupt vector since the FOSSIL was loaded.  It is not suggested
  73.     to use this method.  Instead, it is better to just make the call to the
  74.     "Activate" function 04h and check its return codes.  Almost all current
  75.     applications detect the FOSSIL in this way.  Another method, which only
  76.     works for a few drivers, is to call the "Information" function, and
  77.     check its return codes.  X00 only works correctly if the FOSSIL port
  78.     called is active.  ONEFOSsil and BNU work all the time.  Refer to
  79.     function 1Bh for more information on the "Information" function,;
  80.     however, this method is not suggested either.
  81.  
  82.     Functions
  83.  
  84.     The following functions are supported by most FOSSIL drivers.
  85.  
  86.     Function 00h - Set communications baud, parity, etc.
  87.  
  88.           Input:
  89.                 AH = 00h
  90.                 AL = Communications parameters:
  91.                       010----- = 300 baud
  92.                       011----- = 600 baud
  93.                       100----- = 1200 baud
  94.                       101----- = 2400 baud
  95.                       110----- = 4800 baud
  96.                       111----- = 9600 baud
  97.                       000----- = 19200 baud (replaces IBM 110 baud setting)
  98.                       001----- = 38400 baud (replaces IBM 150 baud setting)
  99.                       ----0--- = No parity
  100.                       ---01--- = Odd parity
  101.                       ---11--- = Even parity
  102.                       -----0-- = 1 stop bit;
  103.                       -----1-- = 1½ bits for 5-bit byte length, 2 for all others
  104.                       ------00 = 5 bits
  105.                       ------01 = 6 bits
  106.                       ------10 = 7 bits
  107.                       ------11 = 8 bits
  108.                 DX = Port number
  109.  
  110.           Output:
  111.                 AH = Line status (see function 03h)
  112.                 AL = Modem status (see function 03h)
  113.  
  114.           This function is identical to the IBM PC INT 14h BIOS call except
  115.           that 110 baud and 150 baud have been replaced by 19200 baud and
  116.           38400 baud respectively.  See function 1Eh for an enhanced version
  117.           of this function.  In addition, once function 1Eh has been used,
  118.           this function will not change the baud rate until function 04h is
  119.           used to reactivate the FOSSIL driver.
  120.  
  121.     Function 01h - Transmit character with wait.
  122.  
  123.           Input:
  124.                 AH = 01h
  125.                 AL = Output character
  126.                 DX = Port number
  127.  
  128.           Output:
  129.                 AH = Line status (see function 03h)
  130.                       1------- = Time-out occurred, all other bits void
  131.                       0------- = Character buffered, all bits valid
  132.                 AL = Modem status (see function 03h, void if time-out occurred)
  133.  
  134.           If there is no room in the transmit buffer, this function will
  135.           wait until there is room in the buffer or until a time-out occurs.
  136.  
  137.           Notes:
  138.  
  139.           ■  X00 executes functions with the interrupt mask set as it was
  140.              when entered.  That is, if X00 is called with interrupts
  141.              masked, interrupts will remain masked during the processing of
  142.              the function.  If this function is called with interrupts
  143.              masked, it may never return.
  144.           ■  ONEFOSsil always enables interrupts upon the beginning of every
  145.              FOSSIL call, so unless there are severe hardware problems,
  146.              ONEFOSsil should always return.
  147.           ■  It is suggested that applications use function 1Bh instead of
  148.              this function in all cases.  This function is slow, and X00 and
  149.              BNU are prone to lock-ups.  Even if the THRE bit is set in a
  150.              status return, there is a chance that the buffer could be
  151.              filled by another application between calls, and as such the
  152.              correct application would get a long, unnecessary delay before
  153.              control is returned.
  154.           ■  Many applications do not check the returned status for a
  155.              time-out condition, and as such drop characters when time-outs
  156.              occur.
  157.  
  158.     Function 02h - Get received character with wait.
  159.  
  160.           Input:
  161.                 AH = 02h
  162.                 DX = Port number
  163.  
  164.           Output:
  165.                 AH = Line status (see function 03h)
  166.                       1------- = Time-out occurred, all other bits void
  167.                       0------- = Character returned, all bits valid
  168.                 AL = Input character (if no time-out occurred)
  169.  
  170.           If no character is available from the receive buffer, this
  171.           function will wait until a character is received or until a
  172.           time-out occurs.
  173.  
  174.           Notes:
  175.  
  176.           ■  X00 executes functions with the interrupt mask set as it was
  177.              when entered.  That is, if X00 is called with interrupts
  178.              masked, interrupts will remain masked during the processing of
  179.              the function.  If this function is called with interrupts
  180.              masked, it may never return.
  181.           ■  ONEFOSsil always enables interrupts upon the beginning of every
  182.              FOSSIL call, so unless there are severe hardware problems,
  183.              ONEFOSsil should always return.
  184.           ■  It is suggested that applications do not use this function.  It
  185.              is slow, and X00 and BNU are prone to lock-ups.  Even if the
  186.              RDA bit is set in a status return, it is possible that another
  187.              application could steal the character, leaving the correct
  188.              application to wait for the next character or a time-out.  It
  189.              is suggested that function 18h be used instead.  Function 18h
  190.              always returns immediately.  Sample code for calling this block
  191.              function in a single character mode can be found in the
  192.              applications notes. Also, X00 and ONEFOSsil support a "get
  193.              character with no wait" at function 20h, but is not supported
  194.              by the FOSSIL 5 specification or most other FOSSIL's.
  195.  
  196.     Function 03h - Return serial port status.
  197.  
  198.           Input:
  199.                 AH = 03h
  200.                 DX = Port number
  201.  
  202.           Output:
  203.                 AH = Line Status (resembles the 8250 Line Status Register)
  204.                       1------- = time-out, all other bits in AH and AL void*
  205.                       -1------ = TSRE, output buffer is empty*
  206.                       --1----- = THRE, room is available in output buffer*
  207.                       ---1---- = BRK, break detected (since last return)
  208.                       ----1--- = FE, framing error detected (since last return)
  209.                       -----1-- = PE, parity error detected (since last return)
  210.                       ------1- = OE, the input buffer has overrun (since last
  211.                                  return)*
  212.                       -------1 = RDA, received data is available in buffer*
  213.                 AL = Modem Status (resembles the 8250 Modem Status Register)
  214.                       1------- = Data carrier detect (DCD)*
  215.                       -1------ = Ring indicator (RI)
  216.                       --1----- = Data set ready (DSR)
  217.                       ---1---- = Clear to send (CTS)
  218.                       ----1--- = Always set to 1 upon return (dummy DCD)*
  219.                       ----1--- = Delta data carrier detect (since last return)
  220.                       -----1-- = Trailing edge ring indicator (since last return)
  221.                       ------1- = Delta data set ready (since last return)
  222.                       -------1 = Delta clear to send (since last return)
  223.  
  224.           * Denotes formal FOSSIL 5 specified bits.
  225.  
  226.           The FOSSIL Specification calls for the delta data carrier detect
  227.           bit to always be set as to act as a dummy DCD.  If an application
  228.           needs a dummy DCD, it should implement it internally as described
  229.           in the notes below.  As such ONEFOSsil does not support it and
  230.           instead uses the bit as a Delta Data Carrier Detect.  ONEFOSsil
  231.           instead includes a command line option to fake Data Carrier
  232.           Detect.
  233.  
  234.           Notes:
  235.  
  236.           ■  All bits without asterisks (*) will vary in meaning from FOSSIL
  237.              to FOSSIL driver.
  238.  
  239.           ■  X00 does not attempt to accurately return the Delta bits.
  240.              ONEFOSsil should correctly return the status of the Delta bits.
  241.  
  242.           ■  One way to implement a dummy DCD is to check the DCD at the
  243.              start of the connection.  If DCD is active, the real DCD should
  244.              be watched.  If DCD is inactive, it should be assumed that
  245.              there might never be a DCD, and assume an internal dummy DCD.
  246.              If DCD was to go active at some later time, real DCD watching
  247.              should be re-enabled and used from there out.
  248.  
  249.     Function 04h - Activate Port.
  250.  
  251.           Input:
  252.                 AH = 04h
  253.                 BX = 0h (in case the FOSSIL supports Control-C flagging)
  254.                 DX = Port number
  255.  
  256.           Output:
  257.                 AX = 1954h if successful
  258.                 BL = Maximum function number supported
  259.                 BH = Revision of FOSSIL specification supported
  260.  
  261.           This function instructs the FOSSIL driver to initialize itself for
  262.           communications on the specified port.  Buffers will be cleared,
  263.           interrupts activated, and DTR raised.  If the port can not be
  264.           supported, the call goes to the next driver or to the system BIOS.
  265.  
  266.           The FOSSIL specification states that the port parameters are not
  267.           to be initialized at this time.  However, with ONEFOSsil, if port
  268.           parameters have been locked on the command line, they will be
  269.           loaded during this time.
  270.  
  271.           The FOSSIL specification calls for an optional Control-C flag, and
  272.           is not supported by X00 or ONEFOSsil.  As such, BX should be
  273.           cleared to prevent any possibility of this occurring.
  274.  
  275.           X00 incorrectly returns the maximum function number (or it isn't
  276.           documented.)  BNU and ONEFOSsil will only return the maximum
  277.           function (currently 20h in ONEFOSsil.)
  278.  
  279.           Multiple calls to this function will repeat the above process as
  280.           if the port had not been open.  If you want to insure the port is
  281.           closed before opening, call function 05h first (many BBS's and
  282.           doors do this.)
  283.  
  284.           Notes:
  285.  
  286.           ■  At some future date, Ray Gwinn intends to make this function
  287.              identical to the PS/2's function 04h.  Function 1Ch is a
  288.              duplicate of this function.  It is my intention to create a new
  289.              standard that will support this, and permit much better
  290.              communications over all devices available.  I do not; however,
  291.              have any opinion on which call should be made.  The latest X00
  292.              and VX00 still support both functions.
  293.  
  294.     Function 05h - Deactivate Port.
  295.  
  296.           Input:
  297.                 AH = 05h
  298.                 DX = Port number
  299.  
  300.           Output:
  301.                Nothing
  302.  
  303.           This function instructs the FOSSIL that it should no longer
  304.           process calls for specified port using the FOSSIL specification.
  305.           This function is passed on to the next driver if the port is not
  306.           active.  Any additional calls to this driver with the specified
  307.           port will also be sent on the next driver or the PC BIOS.  Any
  308.           function not needing a port number, or an active port, will be
  309.           processed by most FOSSIL drivers. X00 will not process
  310.           "Information" requests if the port requested is not active.
  311.  
  312.           ONEFOSsil will attempt to flush the buffers before this function
  313.           will return.  ONEFOSsil will return if a time-out occurs, after
  314.           deactivating the port.  This is to help buggy software that
  315.           deactivate the port before all of their "closing" screen has been
  316.           sent.  It should be assumed however that what is in the transmit
  317.           buffer will be lost when this function is called.
  318.  
  319.           NOTICE: At some future date, Ray Gwinn intends to make this
  320.           function identical to the PS/2's function 05h.  Function 1Dh is a
  321.           duplicate of this function.  It is my intention to create a new
  322.           standard that will support this, and permit much better
  323.           communications over all devices available.  I do not; however,
  324.           have any opinion on which call should be made.  The latest X00 and
  325.           VX00 still support both functions.
  326.  
  327.     Function 06h - Raise/lower DTR.
  328.  
  329.           Input:
  330.                 AH = 06h
  331.                 AL = DTR state to set
  332.                 DX = Port number
  333.  
  334.           Output:
  335.                 Nothing
  336.  
  337.           This function is used to control the DTR signal.  AL is defined as
  338.           follows:
  339.  
  340.                 00h = lower DTR
  341.                 01h = raise DTR
  342.  
  343.           No other function (except functions 04h, 1Ch, and 1Fh) will alter
  344.           DTR.
  345.  
  346.     Function 07h - Return timer tick information.
  347.  
  348.           Input:
  349.                 AH = 07h
  350.  
  351.           Output:
  352.                 AL = Timer tick interrupt number (1Ch or 08h)
  353.                 AH = Approximate interrupts per second (18 on IBM)
  354.                 DX = Approximate number of milliseconds per tick (55)
  355.  
  356.           This function is used to determine the characteristic of the timer
  357.           tick for the computer.
  358.  
  359.           The FOSSIL specification says this function is to return the
  360.           interrupt number, not the vector.  However, most FOSSIL's seem to
  361.           return the vector.  ONEFOSsil also returns the vector, 1Ch.
  362.  
  363.           This function useless today.  I would instead like to see some
  364.           functions that do the timing internally, including calculating the
  365.           time in seconds for the application.  There would need to be 5 or
  366.           6 timers in each port, to allow both BBS's and DOOR software to do
  367.           separate timing.  BBS and DOOR software could use a single
  368.           downward counter/timer for time left on-line, but to actually see
  369.           software implement this would be a miracle.
  370.  
  371.     Function 08h - Flush output buffer.
  372.  
  373.           Input:
  374.                 AH = 08h
  375.                 DX = Port number
  376.  
  377.           Output:
  378.                 Nothing
  379.  
  380.           This function is used to wait until all pending output has been
  381.           transmitted.  It does not return until all buffered output has
  382.           been sent.
  383.  
  384.           This function should be used with care.  Flow control can cause
  385.           the system to hang in a tight un-interruptible loop given the
  386.           right circumstances.
  387.  
  388.           Note:  X00 executes functions with the interrupt mask set as it
  389.           was when entered.  That is, if X00 is called with interrupts
  390.           masked, interrupts will remain masked during the processing of the
  391.           function.  If this function is called with interrupts masked, it
  392.           may never return.
  393.  
  394.           ONEFOSsil will not wait indefinitely and always enables
  395.           interrupts. ONEFOSsil will return if no output has been
  396.           transmitted in the time-out period.  There is no status returned
  397.           to notify the application of this condition.
  398.  
  399.           ONEFOSsil's deactivate function literally calls this function to
  400.           flush the output buffer.
  401.  
  402.           It is advised that this function NOT be used due to the problems
  403.           that could arise.  Instead developers are asked to use function
  404.           03h and wait in their own loop while the TSRE bit is clear.  This
  405.           would permit the application to keep an eye on local keyboard
  406.           activity among other things.
  407.  
  408.     Function 09h - Purge output buffer.
  409.  
  410.           Input:
  411.                 AH = 09h
  412.                 DX = Port number
  413.  
  414.           Output:
  415.                 Nothing
  416.  
  417.           This function is used to remove any buffered output (transmit)
  418.           data.  Any output data remaining in the output buffer (not
  419.           transmitted yet) is discarded.
  420.  
  421.     Function 0Ah - Purge input buffer.
  422.  
  423.           Input:
  424.                 AH = 0Ah
  425.                 DX = Port number
  426.  
  427.           Output:
  428.                 Nothing
  429.  
  430.     This function is used to remove any buffered input (received) data.  Any
  431.     input data which is in the receive buffer is discarded.
  432.  
  433.     Function 0Bh - Transmit no wait.
  434.  
  435.           Input:
  436.                 AH = 0Bh
  437.                 AL = Character
  438.                 DX = Port number
  439.  
  440.           Output:
  441.                 AX > 0000h - Character was buffered for transmission
  442.                    = 0000h - Character was not buffered
  443.  
  444.           This function performs the same operation as function 01h except
  445.           control is returned even if there is no room in the buffer.
  446.  
  447.           It is requested that developers use this function for single
  448.           character transmissions.  It is asked that you also look into
  449.           using function 19h which can transmit more than one character at a
  450.           time.
  451.  
  452.     Function 0Ch - Non-destructive read-ahead (Peek).
  453.  
  454.           Input:
  455.                 AH = 0Ch
  456.                 DX = Port number
  457.  
  458.           Output:
  459.                 AH = 00h if a character is available
  460.                    > 00h if no character is available
  461.                 AL = Next character if available
  462.  
  463.           This function returns the next character from the receive buffer.
  464.           The character returned remains in the receive buffer.  Some
  465.           programmers call this function "peek".
  466.  
  467.           The extended function 20h is a destructive read without wait.
  468.  
  469.     Function 0Dh - Keyboard peek without wait.
  470.  
  471.           Input:
  472.                 AH = 0Dh
  473.  
  474.           Output:
  475.                 AX = IBM-style scan code if available
  476.                    = 0FFFFh if no character is available
  477.  
  478.           This function returns the keyboard scan code of the next character
  479.           from the keyboard.  This is a non-destructive (peek) read of the
  480.           keyboard.
  481.  
  482.           This function should not be used by IBM PC software.
  483.  
  484.     Function 0Eh - Keyboard read with wait.
  485.  
  486.           Input:
  487.                 AH = 0Eh
  488.  
  489.           Output:
  490.                 AX = Keyboard scan code
  491.  
  492.           This function returns the next character available from the
  493.           keyboard.  If no keyboard input is available, this function waits
  494.           until a keyboard character is available.  Returned character codes
  495.           are the same as function 0Dh (IBM style scan codes).
  496.  
  497.           This function should not be used by IBM PC software.
  498.  
  499.     Function 0Fh - Flow Control for serial I/O.
  500.  
  501.           Input:
  502.                 AH = 0Fh
  503.                 AL = Bit defining the flow control to use
  504.                 DX = Port number
  505.  
  506.           Output:
  507.                 Nothing
  508.  
  509.           Two kinds of basic flow control are supported.  One is software,
  510.           called Xon/Xoff flow control.  The other is hardware, called
  511.           RTS/CTS flow control.  Both software and hardware flow control may
  512.           be enabled and used at the same time.
  513.  
  514.           The bits passed in AL are defined as follows:
  515.  
  516.                 Bit 0 = 1   Enable receiving of Xon/Xoff
  517.                 Bit 1 = 1   Enable RTS/CTS flow control
  518.                 Bit 2       Reserved (should be zero)
  519.                 Bit 3 = 1   Enable transmitting of Xon/Xoff
  520.  
  521.           The FOSSIL specification states that all other bits should be set
  522.           to 1 for future expansion.  This is insane, as it might enable
  523.           options the application doesn't want.  It is simpler to assume
  524.           that if the bit is not used now, you wont need to use it later and
  525.           leave it cleared.
  526.  
  527.           ONEFOSsil permits controlling and locking these options on the
  528.           command line.  As such, a request to enable or disable a flow
  529.           control may not be honored.
  530.  
  531.           Some other FOSSIL drivers automatically lock RTS/CTS if the baud
  532.           rate or data parameters are locked on the command line.
  533.  
  534.     Function 10h - Control-C/K checking and transmitter control.
  535.  
  536.           Input:
  537.                 AH = 10h
  538.                 AL = Control bits (defined below)
  539.                 DX = Port number
  540.  
  541.           Output:
  542.                 AX = 0001h - A Control-C/K has been received
  543.                    = 0000h - A Control-C/K has not been received
  544.  
  545.           This is primarily used for BBS operation.  A bit mask is passed in
  546.           AL with the following flags:
  547.  
  548.                 Bit 0 = 1   Enable Control-C/K checking
  549.                 Bit 1 = 1   Disable the transmitter
  550.  
  551.           The Control-C/K status is only returned as long as Control-C/K
  552.           checking is enabled.  The status is cleared after each call.
  553.  
  554.           The transmitter disable bit lets the application program inhibit
  555.           the transmitter.  FIFO's of 16550's can not be stopped, and will
  556.           continue to transmit until empty.
  557.  
  558.           The disable of the transmitter is not absolute.  Several internal
  559.           functions can cause the transmitter to be re-enabled, such as
  560.           attempting to store another character in the buffer.  Some
  561.           FOSSIL's will also re-enable the transmitter when they receive an
  562.           Xon, but ONEFOSsil does not.
  563.  
  564.     Function 11h - Set current cursor location.
  565.  
  566.           Input:
  567.                 AH = 11h
  568.                 DH = Row (line)
  569.                 DL = Column
  570.  
  571.           Output:
  572.           Nothing
  573.  
  574.           This function is exactly like INT 10h, sub-function 2, on the IBM
  575.           PC.  The row and column are relative to zero.  That is, the home
  576.           position on the screen is row 0, column 0.
  577.  
  578.           This function should not be used by IBM PC software.
  579.  
  580.     Function 12h - Read current cursor location.
  581.  
  582.           Input:
  583.                 AH = 12h
  584.  
  585.           Output:
  586.                 DH = Row (line)
  587.                 DL = Column
  588.  
  589.           This function is exactly like INT 10h, sub-function 3, on the IBM
  590.           PC.  The current cursor location (using the same coordinate system
  591.           as function 16h) is returned in DX.
  592.  
  593.           This function should not be used by IBM PC software.
  594.  
  595.     Function 13h - Single character ANSI write to screen.
  596.  
  597.           Input:
  598.                 AH = 13h
  599.                 AL = Character to display
  600.  
  601.           Output:
  602.                 Nothing
  603.  
  604.           The character passed in AL is sent displayed on the screen at the
  605.           current cursor location.   ANSI.SYS type processing is performed.
  606.           This routine should not be used in such a way that DOS output
  607.           (which is not re-entrant) can not be employed by the FOSSIL to
  608.           execute the function.
  609.  
  610.           ANSI.SYS is used by most FOSSIL drivers on the IBM PC.
  611.  
  612.           This function should not be used on IBM PC software.
  613.  
  614.     Function 14h - Enable or disable the DCD watchdog.
  615.  
  616.           Input:
  617.                 AH = 14h
  618.                 AL = 01h - Enable watchdog
  619.                    = 00h - Disable watchdog
  620.                 DX = Port number
  621.  
  622.           Output:
  623.                 Nothing
  624.  
  625.           This function enables and disables the monitoring of carrier
  626.           detect.  When enabled, the state of the carrier detect (DCD) is
  627.           constantly monitored during timer tick processing.  Should carrier
  628.           detect be lost (turned off), the system will be re-booted.
  629.           Activate/deactivate have no effect on the state of the DCD
  630.           watchdog.
  631.  
  632.           This function is not supported by ONEFOSsil, and is dangerous in
  633.           many multitasking environments.
  634.  
  635.     Function 15h - Write character to screen using BIOS.
  636.  
  637.           Input:
  638.                 AH = 15h
  639.                 AL = Character to display
  640.  
  641.           Output:
  642.                 Nothing
  643.  
  644.           The specified character is sent to the screen using BIOS-level
  645.           input/output routines.  This differs from function 13h in that DOS
  646.           I/O will not be used.
  647.  
  648.           This function should not be used by IBM PC software.
  649.  
  650.     Function 16h - Add or delete a routine from the timer tick chain.
  651.  
  652.           Input:
  653.                 AH = 16h
  654.                 AL = 01h - Add a function
  655.                    = 00h - Delete a function
  656.                 ES = Segment of function
  657.                 DX = Offset of function
  658.  
  659.           Output:
  660.                 AX < 0FFFFh if operation is successful
  661.                    = 0FFFFh if operation unsuccessful
  662.  
  663.           This function is used to allow a central authority to manage the
  664.           timer interrupts, so that the integrity of the "timer tick chain"
  665.           is not compromised.  Rather than using the traditional method of
  666.           saving the old contents of the timer vector, storing the address
  667.           of your routine there, and calling the "old" routine, instead you
  668.           call this function.  The FOSSIL manages a list of such entry
  669.           points and calls them on a timer tick (interrupt) using a FAR
  670.           call.
  671.  
  672.           X00 will allow up to 4 programs to hook into the timer tick.
  673.           Interrupts are enabled when the hooked routines are called.
  674.  
  675.           CAUTION:  When this FOSSIL function was implemented, it provided
  676.           the best means to hook into the timer tick on multitasking systems
  677.           at that time.  However, with the 80386 and virtual 8086 mode of
  678.           operation used by DESQview, Windows V3.0+ etc., this function can
  679.           crash the system.  The reason is the virtual 8086 application
  680.           (task/window) that hooked in, may not be the active virtual 8086
  681.           (task/window) when the timer tick interrupt occurs.
  682.  
  683.           Due to popularity of the virtual 8086 type multi-tasking systems,
  684.           Ray Gwinn (who originally insisted that this function be created)
  685.           RECOMMENDS THAT THIS FUNCTION NOT BE USED.
  686.  
  687.           ONEFOSsil returns 0FFFFh in AX at all times.  Happy Ray?
  688.  
  689.     Function 17h - Reboot system.
  690.  
  691.           Input:
  692.                 AH = 17h
  693.                 AL = 00h - "Cold boot"
  694.                    = 01h - "Warm boot"
  695.  
  696.           Output:
  697.                 Nothing
  698.  
  699.           This function is intended primarily as a security feature.  It
  700.           provides the application with a last resort escape from a
  701.           situation that could allow a security breach.
  702.  
  703.           ONEFOSsil attempts to close the task that made the call, rather
  704.           than rebooting what could be a multi-user system.
  705.  
  706.           This function should not be called by ANY software.
  707.  
  708.     Function 18h - Block Read.
  709.  
  710.           Input:
  711.                 AH = 18h
  712.                 CX = Requested number of characters to transfer
  713.                 DX = Port number
  714.                 ES = Segment of the caller's buffer
  715.                 DI = Offset of the caller's buffer
  716.  
  717.           Output:
  718.                 AX = Number of characters actually transferred
  719.  
  720.           This function will transfer from 0 to 65535 characters from the
  721.           inbound circular buffer to the caller's buffer.  ES and DI are not
  722.           modified by this function.  The number returned in AX will be the
  723.           lesser of the caller's requested amount or the entire contents (if
  724.           any) of the receive buffer.
  725.  
  726.           I request that this function be used even for reading a single
  727.           character at a time.  The following examples to help:
  728.  
  729.           In ASM
  730.  
  731.                 push    bp              ;save frame pointer
  732.                 mov     bp,sp           ;set it
  733.                 xor     ax,ax           ;clear temp. value
  734.                 push    ax              ;temporary storage
  735.                 mov     ah,18h          ;function call 18h
  736.                 mov     cx,1            ;get 1 byte
  737.                 mov     dx,port         ;port number
  738.                 lea     di,[bp-2]       ;address of temp. storage
  739.                 push    ss
  740.                 pop     es              ;move registers (size conscious)
  741.                 int     14h             ;make call
  742.                 or      ax,ax           ;any data moved?
  743.                 jnz     @F              ;data was moved
  744.                 mov     [bp-1],0FFh     ;write AH to 0xFF
  745.           @@:   pop     ax              ;if AH = 0, AL = character
  746.                 pop     bp
  747.  
  748.           In C/C++
  749.  
  750.                 No real example available as I would use in-line ASM to
  751.                 accomplish the function very similar to the above code.
  752.                 Other people would use "regs" and "int86" calls.
  753.  
  754.           Notice that you could detect if function 20h is available, and use
  755.           it when possible.  FOSSILC, my C/C++ FOSSIL routines (freeware) do
  756.           exactly that.
  757.  
  758.           This function should especially be used by file transfer protocol
  759.           software.
  760.  
  761.     Function 19h - Block Write.
  762.  
  763.           Input:
  764.                 AH = 19h
  765.                 CX = Requested number of characters to transfer
  766.                 DX = Port number
  767.                 ES = Segment of the caller's buffer
  768.                 DI = Offset of the caller's buffer
  769.  
  770.           Output:
  771.                 AX = Number of characters actually transferred
  772.  
  773.           This function will transfer from 0 to 65535 characters to the
  774.           outbound circular buffer.  ES and DI are not modified by this
  775.           function.  The number returned in AX will be the lesser of the
  776.           caller's requested amount or the amount (if any) required to fill
  777.           the transmit buffer.
  778.  
  779.           This function should be used whenever possible!
  780.  
  781.     Function 1Ah - Break begin or end.
  782.  
  783.           Input:
  784.                 AH = 1Ah
  785.                 AL = 01h - Start sending 'break'
  786.                    = 00h - Stop sending 'break'
  787.                 DX = port number
  788.  
  789.           Output:
  790.                 Nothing
  791.  
  792.           This function will start or terminate a break signal.  This
  793.           function is useful for activating command mode on some modems.
  794.           The application program is responsible for the timing of the
  795.           BREAK.  If ONEFOSsil has been restrained by an Xoff received from
  796.           the modem, the flag will be cleared.  Any port setting functions
  797.           (including 04h and 1Ch) will stop an in progress break.
  798.  
  799.           A break must be maintained long enough for the UART to have sent a
  800.           full data byte at the current settings.  A break is a condition
  801.           where the serial line maintains the state of a start bit for a
  802.           full byte length.
  803.  
  804.     Function 1Bh - Return information about X00.
  805.  
  806.           Input:
  807.                 AH = 1Bh
  808.                 CX = Size of caller's info buffer in bytes
  809.                 DX = Port number
  810.                 ES = Segment of caller's info buffer
  811.                 DI = Offset of caller's info buffer
  812.  
  813.           Output:
  814.                 AX = Number of bytes actually transferred
  815.  
  816.           X00 returns the following:
  817.  
  818.                 CX = '0X'       First 2 bytes of 'X00 ' string
  819.                 DX = ' 0'       Second 2 bytes of 'X00 ' string
  820.  
  821.           ONEFOSsil returns the following:
  822.  
  823.                 BX = 'ON'       No specific byte ordering, just the word
  824.                 CX = 'E '       "ONE " if you were to look at it in a
  825.                                 register dump.
  826.  
  827.           This function will transfer information about the selected port
  828.           and its status to the caller.  This function is intended to assist
  829.           "generic" applications to adjust to the current environment.
  830.  
  831.           Very little information should be used from the returned
  832.           information.  An application should NOT use the buffer size or
  833.           buffer free information for anything.  Use function 03h for
  834.           information about the buffers.
  835.  
  836.           X00 returns the port status (function 03h) if this function is
  837.           called for an inactive port.  BNU and ONEFOSsil return useful
  838.           information if they support the port.
  839.  
  840.           X00 does not always return the following BAUD byte correctly.
  841.           ONEFOSsil contains extra fields in the following structure.
  842.  
  843.           The data structure (assembly language style) currently returned by
  844.           ONEFOSsil is as follows:
  845.  
  846.                 INFO    EQU     $             ;DEFINE BEGIN OF STRUCTURE
  847.                 STRSIZ  DW      INFO_SIZE     ;SIZE OF THIS STRUC IN BYTES
  848.                 MAJVER  DB      CURR_FOSSIL   ;FOSSIL SPECIFICATION REV
  849.                 MINVER  DB      CURR_REV      ;REVISION OF THIS DRIVER.
  850.                 IDENT   DD      ID_STRING     ;"FAR" POINTER TO ASCIIZ
  851.                                               ; DRIVER DESCRIPTION STRING.
  852.                 IBUFR   DW      IBSIZE        ;BYTE SIZE OF THE INPUT BUFFER
  853.                 IFREE   DW      ?             ;BYTES OF RECV BUFFER FREE
  854.                 OBUFR   DW      OBSIZE        ;BYTE SIZE OF THE XMIT BUFFER
  855.                 OFREE   DW      ?             ;BYTES OF XMIT BUFFER FREE
  856.                 SWIDTH  DB      SCREEN_WIDTH  ;WIDTH OF DISPLAY SCREEN
  857.                 SHEIGHT DB      SCREEN_HEIGHT ;HEIGHT OF DISPLAY SCREEN
  858.                 BAUD    DB      ?             ;BAUD RATE, COMPUTER TO MODEM
  859.  
  860.                                         ;the following are extensions
  861.  
  862.                 NEWBAUD DB      ?       ;new baud rate location
  863.                 PORTSET DB      ?       ;complete port data settings
  864.                 OVERRUN DW      ?       ;number overruns this session
  865.  
  866.           The IDENT string is null-terminated, and does not contain a
  867.           new-line.  The BAUD field contains the bits that Function 00h
  868.           would use to set the port speed and data format.
  869.  
  870.           The fields related to a particular port (buffer size, space left
  871.           in the buffer, baud rate) will be undefined if the port is not
  872.           active.
  873.  
  874.           In some cases X00 can not accurately return information.  For
  875.           example, the user can lock the baud rate at 115200 when loading
  876.           X00.  There is no correct FOSSIL value that X00 can return in the
  877.           BAUD field.  X00 will set the BAUD field equal to the last baud
  878.           rate that the application attempted to set, at least that's what
  879.           X00REF.DOC says.  It has been discovered that this is not true,
  880.           and that most the time, the BAUD field contains no usable data.
  881.  
  882.           ONEFOSsil always sets the BAUD parameter to the closest possible
  883.           value.  FHSLink really likes this practice, and as such displays a
  884.           baud rate without using the -B parameter.  ONEFOSsil also uses the
  885.           NEWBAUD and PORTSET bytes.  PORTSET is the bits function 1Eh would
  886.           write to the Line Control Register (minus the break bit).  The
  887.           NEWBAUD byte contains a value similar to what function 1Eh would
  888.           use to set the baud rate.  These are shown below.
  889.  
  890.           Values of NEWBAUD:
  891.  
  892.                 00h = 110       27% error factor on 8250 series
  893.                 01h = 150
  894.                 02h = 300
  895.                 03h = 600
  896.                 04h = 1200
  897.                 05h = 2400
  898.                 06h = 4800
  899.                 07h = 9600
  900.                 08h = 19200
  901.                 09h = 28800
  902.                 0Ah = 38400
  903.                 0Bh = 57600
  904.                 0Ch = 76800     does not exist on 8250 series
  905.                 0Dh = 115200
  906.  
  907.           Values of PORTSET:
  908.  
  909.                 Bit 7 and 6 are always clear
  910.  
  911.                 Bit 3 is set if parity is enabled
  912.                 Bits 5 - 4 define parity:
  913.  
  914.                       00 = Odd parity
  915.                       01 = Even parity
  916.                       10 = Mark parity (sticky odd)
  917.                       11 = Space parity (sticky even)
  918.  
  919.                 Bit 2 defines the number of stop bits transmitted
  920.  
  921.                       0 = 1 stop bit sent
  922.                       1 = 1.5 stop bits for 5 bit bytes, 2 for all others
  923.  
  924.                 Bits 1 - 0 define the number of data bits
  925.  
  926.                       00 = 5 data bits
  927.                       01 = 6 data bits
  928.                       10 = 7 data bits
  929.                       11 = 8 data bits
  930.  
  931.           The OVERRUN word is solely for information.
  932.  
  933.     Extended Functions
  934.  
  935.     Function numbers above 1Bh and below 7Eh are X00 extended functions.
  936.     These functions will only work with X00 and ONEFOSsil.  It is fairly
  937.     easy to see if other FOSSIL's support X00 functions by checking the
  938.     maximum function supported on the "Activate" call.
  939.  
  940.     It is the hope of Ray Gwinn that these functions will be added by other
  941.     FOSSIL authors in their implementations and become a part of the FOSSIL
  942.     specification.  I would personally like to see a whole new, non UART
  943.     specific specification emerge.  This new specification would get rid of
  944.     the inefficiency FOSSIL 5 permits and clear up some of the compatibility
  945.     issues with the new BIOS's.
  946.  
  947.     Functions 1Ch and 1Dh are exact duplicates of FOSSIL functions 04h and
  948.     05h.  Functions 1Eh and 1Fh are intended to be exact duplicates of
  949.     functions 04h and 05h of the PS/2's BIOS INT 14h.  Function 20h is a
  950.     destructive read with no wait.  Function 21h is a Stuff/Poke character
  951.     into the receive buffer.  Note that function 1Eh or 1Fh are not exactly
  952.     compatible with functions 04h and 05h of the PS/2 BIOS.
  953.  
  954.     Developers are encouraged start using functions 1Ch and 1Dh instead of
  955.     functions 04h and 05h.  See the application notes section for
  956.     instructions on a compatible method of determining if functions 1Ch and
  957.     1Dh should be used instead of functions 04h and 05h.
  958.  
  959.     Function 1Ch - Activate Port.
  960.  
  961.           This function is identical to function 04h.  Please refer to
  962.           function 04h for information.
  963.  
  964.     Function 1Dh - Deactivate Port.
  965.  
  966.           This function is identical to function 05h.  Please refer to
  967.           function 05h for information.
  968.  
  969.     Function 1Eh - Extended line control initialization.
  970.  
  971.           This function is intended to exactly emulate the PS/2's BIOS INT
  972.           14 services, function 04h.  Some or all of the functions provided
  973.           here are duplicated by other FOSSIL functions.  In addition, once
  974.           this function is called, function 00h will not be allowed to
  975.           change the baud rate.  Function 00h will again be allowed to set
  976.           the baud rate after the FOSSIL functions have been deactivated.
  977.  
  978.           Input:
  979.                 AH = 1Eh
  980.                 AL = Break, Where:
  981.                    = 00h, No break and/or turn off break
  982.                    = 01h, Start send of break.
  983.                 BH = Parity, where:
  984.                    = 00h, No parity
  985.                    = 01h, Odd parity
  986.                    = 02h, Even parity
  987.                    = 03h, Mark parity (always 1)
  988.                    = 04h, Space parity (always 0)
  989.                 BL = Stop bits, where:
  990.                    = 00h, One bit
  991.                    = 01h, 1.5 bits on 5 bit bytes, 2 stop bits for all others
  992.                 CH = Word length, where:
  993.                    = 00h, 5 bits
  994.                    = 01h, 6 bits
  995.                    = 02h, 7 bits
  996.                    = 03h, 8 bits
  997.                 CL = Baud rate, where:
  998.                    = 00h, 110 baud
  999.                    = 01h, 150 baud
  1000.                    = 02h, 300 baud
  1001.                    = 03h, 600 baud
  1002.                    = 04h, 1200 baud
  1003.                    = 05h, 2400 baud
  1004.                    = 06h, 4800 baud
  1005.                    = 07h, 9600 baud
  1006.                    = 08h, 19200 baud
  1007.                    = 80h, 28800 baud (these are FOSSIL only baud rates)
  1008.                    = 81h, 38400 baud
  1009.                    = 82h, 57600 baud
  1010.                    = 83h, reserved (future 76800 baud)
  1011.                    = 84h, 115200 baud
  1012.                 DX = Port number
  1013.  
  1014.           Output:
  1015.                 AX = Port status (see function 03h)
  1016.  
  1017.           If settings were locked at load time, the appropriate parameters
  1018.           are ignored.
  1019.  
  1020.           ONEFOSsil does not permit the break bit to be set by this
  1021.           function.  The value in AL is ignored.  The reason is that the
  1022.           PS/2 specification calls for a value of 0 to make a break and a 1
  1023.           to clear a break.  X00REF.DOC states the function as it appear
  1024.           above, but the Interrupt shows it as being an exact duplicate of
  1025.           the PS/2 function.  I do not wish to trouble myself with programs
  1026.           that fail to work because their authors used the Interrupt List to
  1027.           write them.
  1028.  
  1029.     Function 1Fh - Extended serial port status/control.
  1030.  
  1031.           This function is intended to exactly emulate the PS/2's BIOS INT
  1032.           14 services, function 05h.  Some or all of the functions provided
  1033.           here are duplicated by other FOSSIL functions.  This function has
  1034.           2 sub-functions specified by AL.
  1035.  
  1036.           Sub-function 00h - Read MCR
  1037.  
  1038.           Input:
  1039.                 AH = 1Fh
  1040.                 AL = 00h, Read modem control register (MCR)
  1041.                 DX = Port number
  1042.  
  1043.           Output:
  1044.                 AX = Port status (see function 03h)
  1045.                 BL = Modem control register, where:
  1046.                       Bits 7-5 = 0 (Reserved) (always 0)
  1047.                       Bit 4    = 1 Loopback mode
  1048.                       Bit 3    = 1 OUT2 (interrupts) enabled
  1049.                       Bit 2    = 1 OUT1 active
  1050.                       Bit 1    = 1 Request to send (RTS) active
  1051.                       Bit 0    = 1 Data terminal ready (DTR) active
  1052.  
  1053.           Sub-function 01h - Write MCR
  1054.  
  1055.           Input:
  1056.                 AH = 1Fh
  1057.                 AL = 01h, Write modem control register (MCR)
  1058.                 BL = Modem control register, where:
  1059.                       Bits 7-5 = 0 (Reserved) (forced 0)
  1060.                       Bit 4    = 1 Set loopback mode
  1061.                       Bit 3    = 1 Set OUT2 enable interrupts (forced 1)
  1062.                       Bit 2    = 1 Set OUT1 active (on)
  1063.                       Bit 1    = 1 Set Request to send active (on)
  1064.                       Bit 0    = 1 Set DTR active (on)
  1065.                 DX = Port number
  1066.  
  1067.           Output:
  1068.                 AX = Port status (see function 03h)
  1069.  
  1070.           In sub-function 01h (write MCR) X00 will force bit 3 to 1.  That
  1071.           is, X00 will not allow the communications interrupts to be
  1072.           disabled.
  1073.  
  1074.           RTS may be used as a flow control signal by the FOSSIL.  When the
  1075.           application program writes the MCR, the RTS bit is treated as an
  1076.           RTS enable bit.  This means that X00 will allow the application
  1077.           program to signal when it wants to allow RTS on.  It does not
  1078.           force RTS on.
  1079.  
  1080.           ONEFOSsil only permits the DTR to be modified with this function.
  1081.           This function should not be used for any reason.  It is hardware
  1082.           specific and such hardware may not exist in the future.
  1083.  
  1084.     Function 20h - Read with no wait (destructive).
  1085.  
  1086.           Input:
  1087.                 AH = 20h
  1088.                 DX = Port number
  1089.  
  1090.           Output:
  1091.                 AH = 00h if a character is available
  1092.                    > 00h if no character is available
  1093.                 AL = Next character if available
  1094.  
  1095.           This function returns the next character from the receive buffer.
  1096.           This function is the same as function 0Ch except that any
  1097.           character returned is removed from the receive buffer.
  1098.  
  1099.     Function 21h - Stuff/Poke the receive buffer.
  1100.  
  1101.           Input:
  1102.                 AH = 20h
  1103.                 AL = Character to place in the receive buffer
  1104.                 DX = Port number
  1105.  
  1106.           Output:
  1107.                 Nothing
  1108.  
  1109.           This function will insert the passed character into the receive
  1110.           buffer (at the end).  Subsequent reading of the serial input will
  1111.           read the character.  The character is inserted at the end of the
  1112.           buffer (as though it were just received.)
  1113.  
  1114.           The character is inserted into the receive buffer by calling the
  1115.           receive interrupt routine.  All normal receive checking is
  1116.           preformed on the character.  Some things to note are:
  1117.  
  1118.           If receiving of Xon/Xoff is enabled and an Xoff is stuffed/poked
  1119.           into the buffer, the transmitter will stop until a an Xon is
  1120.           received or stuffed/poked.
  1121.  
  1122.           If Control-C/K checking is enabled and a Control-C/K is
  1123.           stuffed/poked, then the character is not put in the buffer and the
  1124.           internal flag is set.
  1125.  
  1126.           ONEFOSsil does not support this function as there is no known need
  1127.           for it.
  1128.  
  1129.     "Layered Application" services
  1130.  
  1131.     ONEFOSsil supports NO "Layered Application" services.  The functions
  1132.     simply aren't monitored.  I don't feel most people have any use for
  1133.     them.
  1134.  
  1135.     Application Notes
  1136.  
  1137.     Which Activate/Deactivate functions to use
  1138.  
  1139.     It is the hope of Ray Gwinn (after a period of time) to make X00's
  1140.     functions 04h and 05h compatible with the PS/2's INT 14h functions 04h
  1141.     and 05h.  Currently, X00's functions 04h and 05h are duplicated at
  1142.     functions 1Ch and 1Dh respectively.  Ray requests that application
  1143.     programmers start using functions 1Ch and 1Dh if those functions are
  1144.     available.  That is, use functions 1Ch and 1Dh instead of functions 04h
  1145.     and 05h respectively.
  1146.  
  1147.     It is relatively simple to determine if the functions at 1Ch and 1Dh are
  1148.     available.  When your program is ready to activate the FOSSIL for a
  1149.     given port, issue function 1Ch.  If 1954h is returned, then the port is
  1150.     activated.  If 1954h is not returned, reissue the request to function
  1151.     04h.  Save the function number actually used to activate the port, then
  1152.     increment it by one to deactivate the port.  You may also keep track of
  1153.     the maximum function supported by the driver, to see what other calls
  1154.     are available.  You should; however, leave a user configured option to
  1155.     override all extended function calls.
  1156.  
  1157.     <EoF>
  1158.